/**
 *
 */
package de.cbf.cam.dsa.facet.container.editor;

import static de.cbf.cam.dsa.facet.container.test_support.ConstantsSWTBOTContainer.FACET_CONTAINER_TEXT_VOLUME_ID;
import static de.cbf.util.ui.test_support.ConstantsSWTBOTUtil.DEFAULT_SWT_BOT_KEY;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;

import de.cbf.util.entity.facet.edit.composites.AbstractCompositeEditFacet;
import de.cbf.util.ui.composites.CompositeListEdit;


/**
 * @author Nebelritter
 *
 */
public class CompositeEditContainer extends AbstractCompositeEditFacet {

	public static final int EVT_EDIT_VOLUME = 1;

	protected static final String TEXT_LABEL_VOLUME						= "Volume: ";
	protected static final String TEXT_FOR_TYPES						= "For types.. ";

	protected Text tx_Volume;
	protected CompositeListEdit cp_ListEdit;

	public CompositeEditContainer(Composite parent, int style,FormToolkit toolkit) {
		super(parent, style,toolkit);
	}

	@Override
	protected GridLayout createLayout() {
		return new GridLayout(2, false);
	}

	@Override
	protected void createContent(Composite compositeThis) {
		//volume
		Label lb_Volume = toolkit.createLabel(compositeThis, TEXT_LABEL_VOLUME,SWT.NONE);
		lb_Volume.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_Volume = toolkit.createText(compositeThis, "",SWT.BORDER);
		tx_Volume.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		tx_Volume.setData(DEFAULT_SWT_BOT_KEY, FACET_CONTAINER_TEXT_VOLUME_ID);
		
		cp_ListEdit = createListComposite(TEXT_FOR_TYPES, compositeThis);
		cp_ListEdit.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));				
	}
	
	/**
	 * @param labelText
	 * @param compositeThis
	 */
	protected CompositeListEdit createListComposite(String labelText,Composite compositeThis) {
		CompositeListEdit cp_ListEdit = new CompositeListEdit(compositeThis, SWT.DOUBLE_BUFFERED);
		cp_ListEdit.setHeaderText(labelText);
		return cp_ListEdit;
	}

	public String getVolume() {
		return tx_Volume.getText();
	}

	public void setVolume(String newVolume) {
		if(tx_Volume.getText().equals(newVolume)){
			return;
		}
		tx_Volume.setText(newVolume);
	}
	
	public CompositeListEdit getCompositeForTypes(){
		return cp_ListEdit;				
	}
}
